#!/bin/bash

PATH_CWD=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

source $PATH_CWD/.envsetup

if [ ! -f $PATH_OUT_IMAGE ]; then
   echo "rootfs.img does not exist! Please run build.sh to create it first."
   exit 1
fi

qemu-system-riscv64 -M virt -m 512M -nographic \
    -kernel ${PATH_KERNEL} \
    -drive file=${PATH_OUT_IMAGE},format=raw,id=hd0 \
    -device virtio-blk-device,drive=hd0 \
    -append "root=/dev/vda rw console=ttyS0"
